package boot.spring.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DynamicSqlMapper {

    @Update("${sql}")
    void executeSql(String sql);

    @Select("SELECT COUNT(*) FROM information_schema.tables WHERE TABLE_SCHEMA = #{schema} AND TABLE_NAME = #{table}")
    int tableExists(@Param("schema") String schema, @Param("table") String table);

    @Select("SELECT TABLE_NAME FROM information_schema.tables WHERE TABLE_SCHEMA = #{schema}")
    List<String> listTableNames(@Param("schema") String schema);
}
